import Phaser from 'phaser';
import MainScene from './scenes/official_demos/MainScene.js';
import DemoScene from './scenes/official_demos/DemoScene.js';
import BootScene from './scenes/official_demos/BootScene.js';
import DemoJumpScene from './scenes/official_demos/DemoJumpScene.js';
import ContainerScene from './scenes/runner/container.js';
import GroupScene from  './scenes/runner/group.js';
import CameraViewportDemo from './scenes/runner/camera_mut.js'

// 油管教学视频文件夹
import GameScene from './scenes/tube/gameScene.js'
import MenuCopyScene from './scenes/tube/menuCopyScene.js'
import SplashScene from './scenes/tube/splashScene.js'
import TittleScene from './scenes/tube/tittleScene.js'
let tittleScene = new TittleScene()
let splashScene = new SplashScene()
let menuCopyScene = new MenuCopyScene()
let gameScene = new GameScene()

//list-view
import ListViewScene  from './scenes/runner/list_view.js';
let listViewScene = new ListViewScene()

//runner
import ExtendsOfficialScene from './scenes/runner/extendObj.js';
let extendsOfficialScene = new ExtendsOfficialScene()

//camrea
import CameraScene  from './scenes/runner/camera.js';
let cameraScene = new CameraScene()


//container and group
let containerScene = new ContainerScene()
let groupScene = new GroupScene()


import MenuScene from './scenes/menu_scene.js';

let cameraViewportDemo = new CameraViewportDemo()


let bootScene = new BootScene()

let mainScene = new MainScene()

let demoScene = new DemoScene()

let demoJumpScene = new DemoJumpScene()
let menuScene = new MenuScene()
// Phaser.Scale.NONE：不进行缩放，保持原始尺寸。
// Phaser.Scale.WIDTH_CONTROLS_HEIGHT：根据宽度调整高度，保持宽高比。
// Phaser.Scale.HEIGHT_CONTROLS_WIDTH：根据高度调整宽度，保持宽高比。
// Phaser.Scale.FIT：如上所述，保持宽高比并适应父容器。
// Phaser.Scale.ENVELOP：保持宽高比，但会确保游戏内容填满整个父容器，可能会裁剪掉一部分内容。
// Phaser.Scale.RESIZE：将游戏画布的尺寸设置为父容器的尺寸，不保持宽高比，可能会扭曲画面
// Phaser.Scale.CENTER_HORIZONTALLY：水平居中。
// Phaser.Scale.CENTER_VERTICALLY：垂直居中。
// Phaser.Scale.CENTER_BOTH：两者都居中。
// Phaser.Scale.NO_CENTER：不居中，从左上角开始。

const config = {
  type: Phaser.AUTO,
  width: 800,
  height: 600,
  backgroundColor: '#2d2d2d',
  parent: 'game',
  // scene: [BootScene,DemoScene,MainScene,DemoJumpScene],
  // scene: [SqulashScene],
  physics: {  // 添加物理配置
    default: 'arcade',
    arcade: {
      gravity: { y: 0 },
      debug: false
    }
  },

  scale: {
    mode: Phaser.Scale.FIT,
    autoCenter: Phaser.Scale.CENTER_BOTH
  }
};

window.addEventListener('load', () => {
  const game = new Phaser.Game(config);
  window.game = game; // 方便调试
  // 油管
  game.scene.add('tittleScene', tittleScene)
  game.scene.add('splashScene', splashScene)
  game.scene.add('gameScene', gameScene)
  game.scene.add('menuCopyScene', menuCopyScene)


  //官网案例
  game.scene.add('bootScene', bootScene)
  game.scene.add('mainScene', mainScene)
  game.scene.add('demoScene', demoScene)
  game.scene.add('demoJumpScene', demoJumpScene)

  //list-view
  game.scene.add('listViewScene', listViewScene)

  //runner-api案例
  game.scene.add('extendsOfficialScene',extendsOfficialScene)

  game.scene.add('menuScene', menuScene)
  game.scene.add('cameraScene', cameraScene)
  game.scene.add('groupScene', groupScene)
  game.scene.add('containerScene', containerScene)
  game.scene.add('mutCameraScene', cameraViewportDemo)
  game.scene.start('menuScene')
});
